﻿using System.ComponentModel;
using LSA.Framework;
using QuickGraph;

namespace Visuals.Graph
{
    public class WordsGraphEdge : Edge<WordInfo>, INotifyPropertyChanged
    {
        private double relation;
        public double Relation
        {
            get { return relation; }
            set
            {
                relation = value;
                NotifyPropertyChanged("ID");
            }
        }

        public WordsGraphEdge(WordInfo source, WordRelationPair target) : base(source, target.Word)
        {
            Relation = target.Relation;
        }

        public WordsGraphEdge(WordInfo source, WordInfo target) : base(source, target)
        {
            if (MainWindow.Object == null || MainWindow.Object.lsaSpace == null) return;
            Relation = MainWindow.Object.lsaSpace.RelationBetweenWords(source.Id, target.Id);
        }

        #region INotifyPropertyChanged Implementation

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion
    }
}
